package top.rainbowecho.gateway.security.authentication.social.qq.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.connect.ConnectionFactory;
import top.rainbowecho.gateway.security.authentication.social.qq.connect.QqConnectionFactory;
import top.rainbowecho.gateway.security.property.SecurityProperties;
import top.rainbowecho.gateway.security.property.SocialProperties;

/**
 * @author rainbow
 * @since 2019/12/15 19:36
 */
//@Configuration
//@ConditionalOnProperty(prefix = "blog.security.social.qq", name = "appId")
public class QqAutoConfig extends SocialAutoConfigurerAdapter {
    private SecurityProperties securityProperties;

    @Autowired
    public void setSecurityProperties(SecurityProperties securityProperties) {
        this.securityProperties = securityProperties;
    }

    @Override
    protected ConnectionFactory<?> createConnectionFactory() {
        SocialProperties.QqSocialProperties qqSocialProperties = securityProperties.getAuthentication().getSocial().getQq();

        return new QqConnectionFactory(qqSocialProperties.getProviderId(), qqSocialProperties.getAppId(), qqSocialProperties.getAppSecret());
    }
}
